<?php 
$this->headScript()->appendFile(_STATIC_HTTP . '/admin/js/swfupload.js');
$this->headScript()->appendFile(_STATIC_HTTP . '/admin/js/photoList.js?special_id=' . intval($this->special_id) . '&url=' . $this->url('picture/swfupload/ajaxedit') . '&sid=' . system_session::getId());
$this->headScript()->appendFile(_STATIC_HTTP . '/jquery/json2.js');
$this->headLink()->prependStylesheet(_STATIC_HTTP . '/admin/css/photoBox.css');
$this->headScript()->appendFile(_STATIC_HTTP . '/jquery/checkAll.js');
?>
<?php $this->headScript()->captureStart();?>
$(document).ready(function() {
	swfSetting.flash_url = '<?php echo $this->baseUrl('/swfupload.swf');?>';
	swfSetting.file_types = '<?php echo '*.' . implode(';*.', resource_config_image::getExtensions());?>';
	photo.preview_url = '<?php echo resource_config_image::http(true);?>/';
});
<?php $this->headScript()->captureEnd();?>
<form action="" method="post">
<table class="form photo">
	<tr>
		<th colspan="8"><span style="float:right;"><a href="<?php echo $this->url('picture/photo/batch', array('special_id' => intval($this->special_id)));?>" class="batch"><?php echo $this->language('UPLOAD IN BATCHES');?>..</a></span><?php
			echo '<input type="checkbox" name="select-all" id="select-all" value="1" rel="photo_id[]" />';
			echo '<label class="for-checkbox" for="select-all">&nbsp;' . $this->language('CHECK ALL') . '</label>';
		?></th>
	</tr>
	<?php 
	$count = count($this->list);
	if($count > 0) {
	?>
	<tr>
	<?php
	$key = 1;
	foreach($this->list AS $row) {
		if(isset($this->locale)) {
			$locale = isset($this->locale[$row->getId()]) ? $this->locale[$row->getId()] : false;
			$title = $locale ? $locale->getTitle() : $row->getLocale()->getTitle();
		} else {
			$title = $row->getTitle();
		}
	?>
		<td style="width:<?php echo intval(100/8);?>%;">
			<a href="<?php echo $this->url('picture/photo/edit', array('id' => $row->getId()));?>" class="img">
				<span><img src="<?php echo $row->getImage()->getThumb(false);?>" /></span>
				<em class="t"><?php echo $this->escape($title);?></em>
			</a>
			<div class="clear"></div>
			<p><strong><?php 
				if(in_array($row->getId(), (array)$this->checkedList)) {
					$checked = array('checked' => 'checked');
				} else {
					$checked = array();
				}
				echo $this->form()->checkbox('photo_id[]', $row->getId(), array_merge(array('id' => 'photo-' . $row->getId()), $checked));
				echo '<em class="time"><label for="photo-' . $row->getId() . '" class="for-checkbox">' . $this->date($row->getLastmodified()) . '</label></em>';
			?></strong></p>
		</td>
	<?php
		if($key % 8 == 0 && $key < $count) {
			echo '</tr><tr>';
		}
		$key ++;
	}
	for($i = 0; $i < ((8 - $count % 8) % 8); $i ++) {
		echo '<td style="width:' . intval(100/8) . '%">&nbsp;</td>';
	}		
	?>
	</tr>
	<?php } ?>
	<?php if($count <= 0) {?>
	<tr>
		<td class="nohover">
			<div class="msg">
				<div class="common error" style="border:0;background:#fff;">
					<i class="icon"></i>
					<h4>STOP</h4>
					<div class="msg-bd">
						No Photo found. 
						<a href="<?php echo $this->url('picture/photo/batch', array('special_id' => intval($this->special_id)));?>" class="batch"><?php echo $this->language('UPLOAD');?>..</a>
					</div>
				</div>
			</div>
		</td>
	</tr>
	<?php } ?>
	<tr>
		<th colspan="8"><?php 
		if($this->edit) {
			echo '<button type="submit" name="batch" value="1">' . $this->language('Edit In Batches') . '</button>';
		}
		echo $this->render('include/deleteButton.phtml');
		?></th>
	</tr>
</table>
</form>

<form action="" method="post" id="ajaxForm">
<div class="fixedbox hidden" id="photoLineBox">
	<div class="box">
		<div class="hd">
			<h3><?php echo $this->language('EDIT PHOTO');?></h3>
			<code><a href="#close" onclick="return photo.closeLine();" title="<?php echo $this->language('Close');?>">&times;</a></code>
		</div>
		<div class="bd" id="boxBody"><p>Loading..</p></div>
		<div class="ft">
			<span>
				<a href="#previous" class="previous button" title="<?php echo $this->language('Save data and goto Previous');?>">Previous</a>
				<a href="#next" class="next button" title="<?php echo $this->language('Save data and goto Next');?>">Next</a>
			</span>
			<code>
				<button type="button" value="ajaxSubmit" name="ajaxSubmit" id="ajaxSubmit" class="save"><?php echo $this->language('Save');?></button>
				<?php if(intval($this->special_id) > 0) {?>
				<button type="button" value="setCover" name="setCover" id="setCover" class="save"><?php echo $this->language('Set As Cover');?></button>
				<?php } ?>
				<button type="button" name="close" onclick="return photo.closeLine();" class="cancel"><?php echo $this->language('Cancel');?></button>
			</code>
		</div>
	</div>
</div>
</form>
